home *** CD-ROM | disk | FTP | other *** search
/ Programming Sound Cards / Programming Sound Cards.iso / sound_26 / siren.asm < prev    next >
Assembly Source File  |  1995-01-01  |  4KB  |  87 lines

  1. code_seg        segment
  2.         assume  cs:code_seg
  3.         org     100h
  4.         jmp     start
  5. ;-------------------------------------------
  6. ;B/C Software                        ;Author
  7. ;520 North Stateline Rd
  8. ;Sharon, Pa 16146
  9. ;----------------------------------
  10. count1   dw     8         ;delay counts
  11. count2   dw     3
  12. count3   dw     20
  13. count4   dw     10
  14. message1 db     'press Esc to Quit',0dh,0ah,'$'       ;Esc to end siren
  15. message2 db     'press any other key to play$'        ;or to go again
  16. ;----------------------------------
  17. start   proc    near
  18.         mov     ah,9                 ;DOS function number to print string
  19.         mov     dx,offset message1   ;the message
  20.         int     21h                  ;DOS interrupt
  21.         mov     ah,9                 ;DOS function number to print string
  22.         mov     dx,offset message2   ;the message
  23.         int     21h                  ;DOS interrupt
  24. begin:  mov     ah,0                 ;BIOS function wait for key press
  25.         int     16h                  ;BIOS interrupt
  26.         cmp     ah,1                 ;Esc scan code 
  27.         jz      done                 ;do we stop ?
  28.         call    siren                ;no call phasor sound
  29.         jmp     begin                ;go see if we do it again
  30. done:   mov     ax,4c00h             ;no exit back to DOS
  31.         int     21h                  ;DOS interrupt
  32. start   endp
  33. ;-----------------------------------------
  34. siren   proc    near
  35.         cli                          ;no interrupts
  36.         mov     bp,15                ;we want to do hole thing 15 times
  37.         mov     al,10110110xb        ;set up channel 2
  38.         out     43h,al               ;send it to port
  39. agin:   mov     bx,500               ;start frequency high
  40. backerx:mov     ax,bx                ;place it in (ax)
  41.         out     42h,al               ;send LSB first
  42.         mov     al,ah                ;move MSB into al
  43.         out     42h,al               ;send it next
  44.         in      al,61h               ;get value from port
  45.         or      al,00000011xb        ;ORing it will turn on speaker
  46.         out     61h,al               ;send number
  47.         mov     cx,count1            ;number of delay loops
  48. looperx:loop    looperx              ;so we can hear sound
  49.         inc     bx                   ;increment (bx) lowers frequency pitch
  50.         cmp     bx,4000              ;have we reached 4000
  51.         jnz     backerx              ;if not do again
  52. backery:mov     ax,bx                ;if not put (bx) in (ax)
  53.         out     42h,al               ;send LSB to port
  54.         mov     al,ah                ;place MSB in al
  55.         out     42h,al               ;send it now
  56.         in      al,61h               ;get value from port
  57.         or      al,00000011xb        ;lets OR it
  58.         out     61h,al               ;time to turn on speaker
  59.         mov     cx,count2            ;loop count
  60. loopery:loop    loopery              ;delay so we can hear sound
  61.         dec     bx                   ;decrementing (bx) rises frequency pitch
  62.         cmp     bx,500               ;have we reach 500
  63.         jnz     backery              ;if not go back
  64.         mov     si,count3            ;place longer delay in (si)
  65.         mov     di,count4            ;place longer delay in (di)
  66.         push    si                   ;push it on the stack
  67.         push    di                   ;push it on the stack
  68.         mov     si,count1            ;place first delay in (si)
  69.         mov     di,count2            ;place second delay in (di)
  70.         mov     count3,si            ;save 1st in count3 for next exchange
  71.         mov     count4,di            ;save 2nd in count4 for next exchange
  72.         pop     di                   ;pop longer delay off stack
  73.         pop     si                   ;pop longer delay off stack
  74.         mov     count2,di            ;place it in the second
  75.         mov     count1,si            ;place it in the first
  76.         dec     bp                   ;decrement repeat count
  77.         jnz     agin                 ;if not = 0 do hole thing again
  78.         in      al,61h               ;we be done
  79.         and     al,11111100xb        ;this number will turn speaker off
  80.         out     61h,al               ;send it
  81.         sti                          ;enable interrupts
  82.         ret
  83. siren   endp
  84. ;----------------------------------
  85. code_seg        ends
  86.  
  87.